package com.oa.entities.flows;

import com.oa.domain.UndeleteEntity;
import com.oa.entities.User;

import javax.persistence.*;

@Entity
@Table(name = "oa_apps")
public class Apps extends UndeleteEntity<Long> {
    /**
     *
     */
    private static final long serialVersionUID = -4462596055211576764L;

    /** 公文的名称 **/
    public static final String APPS_NAME="name";

    /** 公文的标题 **/
    public static final String APPS_TITLE="title";

    /** 公文类型 **/
    public static final String APPS_TYPE="type";

    public static final String APPS_SENDTIME="issueTime";

    /** 用户的id **/
    public static final String PERSONNEL_USER_ID="personnel."+Personnel.PERSONNEL_USER_ID;

    /** 公文的状态 **/
    public static final String APPS_APPS_TYPE="appsType";

    /** 文档的名称 **/
    private String name;

    /** 文档的标题 **/
    private String title;

    /** 编号 **/
    private Long number;

    /** 类型 **/
    private int type;

    /** 类型 **/
    private AppType appType;

    /** **/
    private int appsType;

    /** 发起时间 **/
    private Long issueTime;

    /** 发起人 **/
    private User issue;

    /** 记录 **/
    private Personnel personnel;

    /** 审核时间 **/
    private Long approvaldate;

    @Override
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return super.getId();
    }

    @Override
    public void setId(Long id) {
        super.setId(id);
    }

    @Column(name = "apps_name",nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "apps_title",nullable = false)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Column(name = "apps_number")
    public Long getNumber() {
        return number;
    }

    public void setNumber(Long number) {
        this.number = number;
    }

    @Column(name = "type",nullable = false)
    public int getType() {
        return type;
    }

    /**apps_type_id
     * @see com.oa.common.enums.AppsType
     * @param type
     */
    public void setType(int type) {
        this.type = type;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "apps_type_id",nullable = false)
    public AppType getAppType() {
        return appType;
    }

    public void setAppType(AppType appType) {
        this.appType = appType;
    }

    @Column(name = "app_type",nullable = false)
    public int getAppsType() {
        return appsType;
    }

    /**
     * @name 设置
     * @see  com.oa.common.enums.PersonType
     * @param appsType
     */
    public void setAppsType(int appsType) {
        this.appsType = appsType;
    }

    @Column(name = "issue_time",nullable = false)
    public Long getIssueTime() {
        return issueTime;
    }

    public void setIssueTime(Long issueTime) {
        this.issueTime = issueTime;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "issue_id")
    public User getIssue() {
        return issue;
    }

    public void setIssue(User issue) {
        this.issue = issue;
    }

    @Override
    public String toString() {
        return "Apps{" +
                "name='" + name + '\'' +
                ", title='" + title + '\'' +
                ", number=" + number +
                ", type=" + type +
                ", appType=" + appType +
                ", appsType=" + appsType +
                ", issueTime=" + issueTime +
                ", issue=" + issue +
                '}';
    }

    @OneToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL,mappedBy = "apps")
    public Personnel getPersonnel() {
        return personnel;
    }

    public void setPersonnel(Personnel personnel) {
        this.personnel = personnel;
    }

    @Column(name = "approval_date")
    public Long getApprovaldate() {
        return approvaldate;
    }

    public void setApprovaldate(Long approvaldate) {
        this.approvaldate = approvaldate;
    }
}
